package me.jiatao.wan.data.network.api

import me.jiatao.wan.data.network.HttpResult
import me.jiatao.wan.data.network.pojo.*
import retrofit2.http.*

/**
 * @Author: taojia
 * @CreateDate: 2021/8/24 3:49 下午
 * @Version: 1.0
 * @Description:
 */

interface WanAndroidApi {
    //开源API:http://gank.io/api/search/query/listview/category/Android/count/10/page/1

    /**
     * 轮播图数据
     */
    @GET("banner/json")
    suspend fun fetchBannerListApi(): HttpResult<List<BannerPojo>>

    /**
     * 首页置顶文章列表
     */
    @GET("article/top/json")
    suspend fun fetchTopArticleListApi(): HttpResult<List<ArticlePojo>>

    /**
     * 首页文章列表
     */
    @GET("article/list/{pageIndex}/json")
    suspend fun fetchHomeArticleListApi(@Path("pageIndex") pageIndex: Int): HttpResult<ArticlePagePojo>

    /**
     * 获取类别列表
     */
    @GET("project/tree/json")
    suspend fun fetchProjectTreeApi(): HttpResult<List<CategoryTreePojo>>

    /**
     * https://www.wanandroid.com/project/list/1/json?cid=294
     */
    @GET("project/list/{pageIndex}/json")
    suspend fun fetchProjectArticleListApi(
        @Path("pageIndex") pageIndex: Int,
        @Query("cid") cid: Int
    ): HttpResult<ArticlePagePojo>


    /**
     * 获取体系列表
     */
    @GET("tree/json")
    suspend fun fetchCategoryTreeApi(): HttpResult<List<CategoryTreePojo>>

    /**
     * 获取常用网址
     */
    @GET("navi/json")
    suspend fun fetchNavTreeApi(): HttpResult<List<NavTreePojo>>

    /**
     * 用户登录
     */
    @POST("user/login")
    @FormUrlEncoded
    suspend fun postUserLogin(
        @Field("username") userName: String,
        @Field("password") userPwd: String
    ): HttpResult<UserLoginPojo>
}